object dmSPED: TdmSPED
  OldCreateOrder = False
  OnCreate = DataModuleCreate
  OnDestroy = DataModuleDestroy
  Left = 538
  Top = 130
  Height = 876
  Width = 833
  object tqEntidade: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'Select EMP_CODIGO, EMP_RAZAO, Emp_CNPJ, EST_SIGLA, EMP_INSCEST, ' +
        'CID_CODMUNICIPIO, EMP_INSCMUNICIPAL, EMP_IND_ATIV,'
      
        'EMP_FANTASIA, EMP_CEP, EMP_ENDERECO, EMP_NUMERO, EMP_COMPLEMENTO' +
        ', EMP_BAIRRO, EMP_TELEFONE, EMP_FAX, EMP_EMAIL'
      'from Empresa e, Cidade c'
      'where e.Cid_Codigo = c.Cid_Codigo'
      'and Emp_Codigo = :Empr')
    Left = 24
    Top = 64
    ParamData = <
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end>
  end
  object dspEntidade: TDataSetProvider
    DataSet = tqEntidade
    Left = 56
    Top = 64
  end
  object CDSEntidade: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspEntidade'
    Left = 88
    Top = 64
    object CDSEntidadeEMP_RAZAO: TStringField
      FieldName = 'EMP_RAZAO'
      Size = 40
    end
    object CDSEntidadeEMP_CNPJ: TStringField
      FieldName = 'EMP_CNPJ'
      Size = 18
    end
    object CDSEntidadeEST_SIGLA: TStringField
      FieldName = 'EST_SIGLA'
      Size = 2
    end
    object CDSEntidadeEMP_INSCEST: TStringField
      FieldName = 'EMP_INSCEST'
      Size = 15
    end
    object CDSEntidadeCID_CODMUNICIPIO: TStringField
      FieldName = 'CID_CODMUNICIPIO'
      Size = 7
    end
    object CDSEntidadeEMP_INSCMUNICIPAL: TStringField
      FieldName = 'EMP_INSCMUNICIPAL'
      Size = 19
    end
    object CDSEntidadeEMP_IND_ATIV: TStringField
      FieldName = 'EMP_IND_ATIV'
      FixedChar = True
      Size = 1
    end
    object CDSEntidadeEMP_FANTASIA: TStringField
      FieldName = 'EMP_FANTASIA'
      Size = 30
    end
    object CDSEntidadeEMP_CEP: TStringField
      FieldName = 'EMP_CEP'
      Size = 9
    end
    object CDSEntidadeEMP_ENDERECO: TStringField
      FieldName = 'EMP_ENDERECO'
      Size = 40
    end
    object CDSEntidadeEMP_NUMERO: TStringField
      FieldName = 'EMP_NUMERO'
      Size = 10
    end
    object CDSEntidadeEMP_COMPLEMENTO: TStringField
      FieldName = 'EMP_COMPLEMENTO'
      Size = 60
    end
    object CDSEntidadeEMP_BAIRRO: TStringField
      FieldName = 'EMP_BAIRRO'
      Size = 25
    end
    object CDSEntidadeEMP_TELEFONE: TStringField
      FieldName = 'EMP_TELEFONE'
      Size = 10
    end
    object CDSEntidadeEMP_FAX: TStringField
      FieldName = 'EMP_FAX'
      Size = 10
    end
    object CDSEntidadeEMP_EMAIL: TStringField
      FieldName = 'EMP_EMAIL'
      Size = 50
    end
    object CDSEntidadeEMP_CODIGO: TStringField
      FieldName = 'EMP_CODIGO'
      Size = 3
    end
  end
  object Db: TDatabase
    AliasName = 'Industrial'
    DatabaseName = 'industrial'
    LoginPrompt = False
    Params.Strings = (
      'PASSWORD=crit')
    SessionName = 'Default'
    Left = 16
    Top = 8
  end
  object tqUFIEST: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsEntidade
    SQL.Strings = (
      'Select * from UF_IEST'
      'where EMP_CODIGO = :Empr')
    Left = 24
    Top = 112
    ParamData = <
      item
        DataType = ftString
        Name = 'EMPR'
        ParamType = ptInput
      end>
  end
  object dspUFIEST: TDataSetProvider
    DataSet = tqUFIEST
    Left = 56
    Top = 112
  end
  object CDSUFIEST: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspUFIEST'
    Left = 88
    Top = 112
    object CDSUFIESTEST_SIGLA: TStringField
      FieldName = 'EST_SIGLA'
      Size = 2
    end
    object CDSUFIESTEMP_INSCEST_SUBST: TStringField
      FieldName = 'EMP_INSCEST_SUBST'
      Size = 15
    end
  end
  object dsEntidade: TDataSource
    DataSet = CDSEntidade
    Left = 120
    Top = 64
  end
  object tqContabilista: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'Select Cont_Nome, Cont_CPF, Cont_CRC, Cont_CNPJ, Cont_CEP, Cont_' +
        'Endereco, Cont_Numero, Cont_Complemento, Cont_Bairro, Cont_Fone,' +
        ' Cont_Fax, Cont_Email, CID_CODMUNICIPIO'
      'from Contabilista c, Cidade i'
      'where c.Cid_Codigo = i.Cid_Codigo')
    Left = 24
    Top = 160
  end
  object dspContabilista: TDataSetProvider
    DataSet = tqContabilista
    Left = 56
    Top = 160
  end
  object CDSContabilista: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspContabilista'
    Left = 88
    Top = 160
    object CDSContabilistaCONT_NOME: TStringField
      FieldName = 'CONT_NOME'
      Size = 60
    end
    object CDSContabilistaCONT_CPF: TStringField
      FieldName = 'CONT_CPF'
      Size = 11
    end
    object CDSContabilistaCONT_CRC: TStringField
      FieldName = 'CONT_CRC'
      Size = 15
    end
    object CDSContabilistaCONT_CNPJ: TStringField
      FieldName = 'CONT_CNPJ'
      Size = 14
    end
    object CDSContabilistaCONT_CEP: TStringField
      FieldName = 'CONT_CEP'
      Size = 8
    end
    object CDSContabilistaCONT_ENDERECO: TStringField
      FieldName = 'CONT_ENDERECO'
      Size = 60
    end
    object CDSContabilistaCONT_NUMERO: TStringField
      FieldName = 'CONT_NUMERO'
      Size = 10
    end
    object CDSContabilistaCONT_COMPLEMENTO: TStringField
      FieldName = 'CONT_COMPLEMENTO'
      Size = 60
    end
    object CDSContabilistaCONT_BAIRRO: TStringField
      FieldName = 'CONT_BAIRRO'
      Size = 60
    end
    object CDSContabilistaCONT_FONE: TStringField
      FieldName = 'CONT_FONE'
      Size = 10
    end
    object CDSContabilistaCONT_FAX: TStringField
      FieldName = 'CONT_FAX'
      Size = 10
    end
    object CDSContabilistaCONT_EMAIL: TStringField
      FieldName = 'CONT_EMAIL'
      Size = 70
    end
    object CDSContabilistaCID_CODMUNICIPIO: TStringField
      FieldName = 'CID_CODMUNICIPIO'
      Size = 7
    end
  end
  object tqParticipante: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'Select distinct e.ent_codigo, ent_nome, PAIS_CODIBGE, ent_cnpj, ' +
        'ent_cpf, ent_inscest, CID_CODMUNICIPIO, Cod_Suframa, END_Enderec' +
        'o, End_Numero, End_Bairro'
      
        'from Entidade e, Endereco d, Cidade c, Pais p, NotaVenda vda, No' +
        'taCompra cpa, Transportadora t'
      'where '
      '(e.ent_codigo = d.ent_codigo and d.end_codigo in ('#39'01'#39'))'
      'and d.cid_codigo  = c.cid_codigo'
      'and c.pais_codigo = p.pais_codigo'
      'and t.ent_codigo(+) = e.ent_codigo'
      'and'
      '('
      
        '(e.ent_codigo = vda.ent_codigo and  notv_datafat >= :dtIni and n' +
        'otv_dataFat <= :dtFim and vda.MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39'04'#39','#39'55'#39 +
        ','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and vda.Emp_Codigo = :Empr and v' +
        'da.canp_codigo is null)'
      'or'
      
        '(e.ent_codigo = cpa.ent_codigo and  notc_datafatura >= :dtIni an' +
        'd notc_datafatura <= :dtFim and cpa.MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39'04' +
        #39','#39'55'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and cpa.Emp_Codigo = (:Emp' +
        'r) and cpa.canp_codigo is null)'
      'or'
      
        '(t.tran_codigo = vda.tran_codigo and  notv_datafat >= :dtIni and' +
        ' notv_dataFat <= :dtFim and vda.MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39'04'#39','#39'5' +
        '5'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and vda.Emp_Codigo = :Empr and' +
        ' vda.canp_codigo is null)'
      'or'
      
        '(t.tran_codigo = cpa.tran_codigo and  notc_datafatura >= :dtIni ' +
        'and notc_datafatura <= :dtFim and cpa.MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39 +
        '04'#39','#39'55'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and cpa.Emp_Codigo = (:E' +
        'mpr) and cpa.canp_codigo is null)')
    Left = 24
    Top = 208
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end>
  end
  object dspParticipante: TDataSetProvider
    DataSet = tqParticipante
    Left = 56
    Top = 208
  end
  object CDSParticipante: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspParticipante'
    Left = 88
    Top = 208
    object CDSParticipanteENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSParticipanteENT_NOME: TStringField
      FieldName = 'ENT_NOME'
      Size = 80
    end
    object CDSParticipantePAIS_CODIBGE: TStringField
      FieldName = 'PAIS_CODIBGE'
      Size = 5
    end
    object CDSParticipanteENT_CNPJ: TStringField
      FieldName = 'ENT_CNPJ'
      Size = 18
    end
    object CDSParticipanteENT_CPF: TStringField
      FieldName = 'ENT_CPF'
      Size = 14
    end
    object CDSParticipanteENT_INSCEST: TStringField
      FieldName = 'ENT_INSCEST'
      Size = 21
    end
    object CDSParticipanteCID_CODMUNICIPIO: TStringField
      FieldName = 'CID_CODMUNICIPIO'
      Size = 7
    end
    object CDSParticipanteCOD_SUFRAMA: TStringField
      FieldName = 'COD_SUFRAMA'
      Size = 9
    end
    object CDSParticipanteEND_ENDERECO: TStringField
      FieldName = 'END_ENDERECO'
      Size = 46
    end
    object CDSParticipanteEND_NUMERO: TStringField
      FieldName = 'END_NUMERO'
      Size = 10
    end
    object CDSParticipanteEND_BAIRRO: TStringField
      FieldName = 'END_BAIRRO'
      Size = 25
    end
  end
  object tqAltParticipante: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select e.ENT_CODIGO_V, e.DATA_HORA,'
      'case when ENT_NOME_V <> ENT_NOME_N then'
      ' '#39'03'#39
      'else'
      ' case when ENT_CNPJ_V <> ENT_CNPJ_N then'
      '  '#39'05'#39
      ' else'
      '  case when ENT_CPF_V <> ENT_CPF_N then'
      '   '#39'06'#39
      '  else'
      '   case when ENT_INSCEST_V <> ENT_INSCEST_N then'
      '    '#39'07'#39
      '   else'
      '    case when CID_CODIGO_V <> CID_CODIGO_N then'
      '     '#39'08'#39
      '    else'
      '     case when COD_SUFRAMA_V <> COD_SUFRAMA_N then'
      '      '#39'09'#39
      '     else'
      '      case when END_ENDERECO_V <> END_ENDERECO_N then'
      '       '#39'10'#39
      '      else'
      '       case when END_NUMERO_V <> END_NUMERO_N then'
      '        '#39'11'#39
      '       else'
      '        case when END_COMPLEMENTO_V <> END_COMPLEMENTO_N then'
      '         '#39'12'#39
      '        else'
      '         case when END_BAIRRO_V <> END_BAIRRO_V then'
      '          '#39'13'#39
      '         end'
      '        end'
      '       end'
      '      end'
      '     end'
      '    end'
      '   end'
      '  end'
      ' end'
      'end as NR_CAMPO,'
      'case when ENT_NOME_V <> ENT_NOME_N then'
      ' ENT_NOME_V'
      'else'
      ' case when ENT_CNPJ_V <> ENT_CNPJ_N then'
      '  ENT_CNPJ_V'
      ' else'
      '  case when ENT_CPF_V <> ENT_CPF_N then'
      '   ENT_CPF_V'
      '  else'
      '   case when ENT_INSCEST_V <> ENT_INSCEST_N then'
      '    ENT_INSCEST_V'
      '   else'
      '    case when CID_CODIGO_V <> CID_CODIGO_N then'
      '     CID_CODIGO_V'
      '    else'
      '     case when COD_SUFRAMA_V <> COD_SUFRAMA_N then'
      '      COD_SUFRAMA_V'
      '     else'
      '      case when END_ENDERECO_V <> END_ENDERECO_N then'
      '       END_ENDERECO_V'
      '      else'
      '       case when END_NUMERO_V <> END_NUMERO_N then'
      '        END_NUMERO_V'
      '       else'
      '        case when END_COMPLEMENTO_V <> END_COMPLEMENTO_N then'
      '         END_COMPLEMENTO_V'
      '        else'
      '         case when END_BAIRRO_V <> END_BAIRRO_V then'
      '          END_BAIRRO_V'
      '         end'
      '        end'
      '       end'
      '      end'
      '     end'
      '    end'
      '   end'
      '  end'
      ' end'
      'end as CONT_ANT'
      'from LOG_SPED_ENTIDADE e, LOG_SPED_ENDERECO d'
      'where e.ENT_CODIGO_V = d.ENT_CODIGO_V'
      'and e.data_hora >=:dtIni')
    Left = 24
    Top = 256
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptUnknown
      end>
  end
  object dspAltParticipante: TDataSetProvider
    DataSet = tqAltParticipante
    Left = 56
    Top = 256
  end
  object CDSAltParticipante: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspAltParticipante'
    AfterOpen = CDSAltParticipanteAfterOpen
    Left = 96
    Top = 256
    object CDSAltParticipanteDATA_HORA: TDateTimeField
      FieldName = 'DATA_HORA'
    end
    object CDSAltParticipanteNR_CAMPO: TStringField
      FieldName = 'NR_CAMPO'
      FixedChar = True
      Size = 2
    end
    object CDSAltParticipanteCONT_ANT: TStringField
      FieldName = 'CONT_ANT'
      Size = 80
    end
    object CDSAltParticipanteENT_CODIGO_V: TStringField
      FieldName = 'ENT_CODIGO_V'
      Size = 5
    end
  end
  object dsParticipante: TDataSource
    DataSet = CDSParticipante
    Left = 120
    Top = 208
  end
  object tqUnidade: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select distinct UND_CODIGO, UND_DESCRICAO, p.Pro_codigo'
      'from UNIDADE_MEDIDA u, Produto p'
      'where PRO_UNIDADE = UND_CODIGO'
      'and'
      '('
      '( Pro_Codigo in'
      
        '                                         (Select distinct Pro_Co' +
        'digo from ItemNotaVenda'
      
        '                                           where Itnv_DataFat >=' +
        ' :dtIni  and Itnv_DataFat <= :dtFim'
      '                                          )'
      ')'
      'or'
      '( Pro_Codigo in'
      
        '                                         (Select distinct Pro_Co' +
        'digo from ItemNotaCompra'
      
        '                                           where Itnc_DataEntrad' +
        'a >= :dtIni  and Itnc_DataEntrada <= :dtFim'
      '                                          )'
      ')'
      ')')
    Left = 24
    Top = 304
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end>
  end
  object dspUnidade: TDataSetProvider
    DataSet = tqUnidade
    Left = 56
    Top = 304
  end
  object CDSUnidade: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspUnidade'
    Left = 88
    Top = 304
    object CDSUnidadeUND_CODIGO: TStringField
      FieldName = 'UND_CODIGO'
      Size = 3
    end
    object CDSUnidadeUND_DESCRICAO: TStringField
      FieldName = 'UND_DESCRICAO'
      Size = 60
    end
    object CDSUnidadePRO_CODIGO: TStringField
      FieldName = 'PRO_CODIGO'
    end
  end
  object tqItem: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'select p.PRO_CODIGO, PRO_NOME, PRO_EAN, PRO_UNIDADE, FASE_TIPO A' +
        'S FASE_CODIGO, Trim(replace(nbm_desc,'#39'.'#39','#39#39')) COD_NCM,'
      'PRO_ALIQICMS'
      'from Produto p, NBM n, PRODEAN c, FASEPROCESSO F'
      'where p.NBM_CODIGO = n.nbm_codigo'
      'and p.Fase_codigo = f.fase_codigo(+)'
      'and p.Pro_codigo = c.pro_codigo(+)'
      'and '
      '('
      'p.Pro_Codigo in'
      
        '                                         (Select distinct Pro_Co' +
        'digo from ItemNotaVenda i, NotaVenda n'
      
        '                                           where n.Nota_Serie||n' +
        '.Nota_Numero||n.Ent_Codigo = i.Nota_Serie||i.Nota_Numero||i.Ent_' +
        'Codigo'
      
        '                                           and  notv_datafat >= ' +
        ':dtIni and notv_dataFat <= :dtFim and n.Emp_Codigo =:Empr'
      
        '                                           and ((n.MOD_CODIGO IN' +
        ' ('#39'01'#39','#39'1B'#39','#39'04'#39','#39'06'#39','#39'29'#39','#39'28'#39')) or (mod_codigo = '#39'55'#39' and notv' +
        '_emitente = '#39'T'#39'))'
      
        '                                           and ref_numero is nul' +
        'l'
      '                                          )'
      ' or'
      '    p.Pro_Codigo in'
      
        '                                         (Select distinct Pro_Co' +
        'digo from ItemNotaCompra i, NotaCompra n'
      
        '                                           where n.Notc_Serie||n' +
        '.Notac_Numero||n.Ent_Codigo = i.Notc_Serie||i.Notac_Numero||i.En' +
        't_Codigo'
      
        '                                               and  notc_datafat' +
        'ura >= :dtIni and notc_datafatura <= :dtFim  and n.Emp_Codigo =:' +
        'Empr'
      
        '                                               and ((n.MOD_CODIG' +
        'O IN ('#39'01'#39','#39'1B'#39','#39'04'#39')) or (mod_codigo = '#39'55'#39' and notc_emitente =' +
        ' '#39'T'#39'))'
      
        '                                               and ref_notac_num' +
        'ero is null'
      '                                          )'
      ')')
    Left = 24
    Top = 352
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end>
  end
  object dspItem: TDataSetProvider
    DataSet = tqItem
    Left = 56
    Top = 352
  end
  object CDSItem: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspItem'
    Left = 88
    Top = 352
    object CDSItemPRO_CODIGO: TStringField
      FieldName = 'PRO_CODIGO'
    end
    object CDSItemPRO_NOME: TStringField
      FieldName = 'PRO_NOME'
      Size = 70
    end
    object CDSItemPRO_EAN: TStringField
      FieldName = 'PRO_EAN'
      Size = 40
    end
    object CDSItemPRO_UNIDADE: TStringField
      FieldName = 'PRO_UNIDADE'
      Size = 3
    end
    object CDSItemFASE_CODIGO: TStringField
      FieldName = 'FASE_CODIGO'
      Size = 2
    end
    object CDSItemCOD_NCM: TStringField
      FieldName = 'COD_NCM'
      Size = 12
    end
    object CDSItemPRO_ALIQICMS: TFloatField
      FieldName = 'PRO_ALIQICMS'
    end
  end
  object dsItem: TDataSource
    DataSet = CDSItem
    Left = 120
    Top = 352
  end
  object tqAltItem: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select * from LOG_SPED_PRODUTO'
      'where Pro_codigo_V =:Pro_codigo'
      'and DATA_HORA >= :dtINI')
    Left = 24
    Top = 400
    ParamData = <
      item
        DataType = ftString
        Name = 'PRO_CODIGO'
        ParamType = ptUnknown
        Size = 21
      end
      item
        DataType = ftDate
        Name = 'dtINI'
        ParamType = ptInput
      end>
  end
  object dspAltItem: TDataSetProvider
    DataSet = tqAltItem
    Left = 56
    Top = 400
  end
  object CDSAltItem: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspAltItem'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 400
    object CDSAltItemDATA_HORA: TDateTimeField
      FieldName = 'DATA_HORA'
    end
    object CDSAltItemOPERACAO: TStringField
      FieldName = 'OPERACAO'
      Size = 10
    end
    object CDSAltItemPRO_CODIGO_V: TStringField
      FieldName = 'PRO_CODIGO_V'
    end
    object CDSAltItemPRO_CODIGO_N: TStringField
      FieldName = 'PRO_CODIGO_N'
    end
    object CDSAltItemPRO_NOME_V: TStringField
      FieldName = 'PRO_NOME_V'
      Size = 70
    end
    object CDSAltItemPRO_NOME_N: TStringField
      FieldName = 'PRO_NOME_N'
      Size = 70
    end
  end
  object tqFator: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select * from LOG_SPED_PRODUTO'
      'where Pro_codigo_V =:Pro_codigo'
      'and DATA_HORA >= :dtINI')
    Left = 24
    Top = 448
    ParamData = <
      item
        DataType = ftString
        Name = 'PRO_CODIGO'
        ParamType = ptUnknown
        Size = 21
      end
      item
        DataType = ftDate
        Name = 'dtINI'
        ParamType = ptInput
      end>
  end
  object dspFator: TDataSetProvider
    DataSet = tqFator
    Left = 56
    Top = 448
  end
  object CDSFator: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspFator'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 448
    object DateTimeField1: TDateTimeField
      FieldName = 'DATA_HORA'
    end
    object StringField1: TStringField
      FieldName = 'OPERACAO'
      Size = 10
    end
    object StringField2: TStringField
      FieldName = 'PRO_CODIGO_V'
    end
    object StringField3: TStringField
      FieldName = 'PRO_CODIGO_N'
    end
    object StringField4: TStringField
      FieldName = 'PRO_NOME_V'
      Size = 70
    end
    object StringField5: TStringField
      FieldName = 'PRO_NOME_N'
      Size = 70
    end
  end
  object tqBem: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select * from BEM')
    Left = 24
    Top = 496
  end
  object dspBem: TDataSetProvider
    DataSet = tqBem
    Left = 56
    Top = 496
  end
  object CDSBem: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspBem'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 496
    object CDSBemCOD_IND_BEM: TStringField
      FieldName = 'COD_IND_BEM'
      Size = 60
    end
    object CDSBemIDENT_MERC: TStringField
      FieldName = 'IDENT_MERC'
      FixedChar = True
      Size = 1
    end
    object CDSBemDESCR_ITEM: TMemoField
      FieldName = 'DESCR_ITEM'
      BlobType = ftMemo
      Size = 2000
    end
    object CDSBemCOD_PRNC: TStringField
      FieldName = 'COD_PRNC'
      Size = 60
    end
    object CDSBemHIST_CODIGO: TStringField
      FieldName = 'HIST_CODIGO'
      Size = 10
    end
    object CDSBemNR_PARC: TFloatField
      FieldName = 'NR_PARC'
    end
    object CDSBemDEP_CODIGO: TStringField
      FieldName = 'DEP_CODIGO'
      Size = 2
    end
    object CDSBemFUNC: TMemoField
      FieldName = 'FUNC'
      BlobType = ftMemo
      Size = 2000
    end
    object CDSBemVIDA_UTIL: TFloatField
      FieldName = 'VIDA_UTIL'
    end
  end
  object SPED: TACBrSPEDFiscal
    Path = 'C:\Program Files\Borland\Delphi7\Bin\'
    Delimitador = '|'
    TrimString = True
    CurMascara = '#0.00'
    Left = 48
    Top = 8
  end
  object CDSNatOper: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspNatOper'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 544
    object CDSNatOperNATO_CODIGO: TStringField
      FieldName = 'NATO_CODIGO'
      Size = 2
    end
    object CDSNatOperNATO_DESCRICAO: TStringField
      FieldName = 'NATO_DESCRICAO'
      Size = 75
    end
  end
  object dspNatOper: TDataSetProvider
    DataSet = tqNatOper
    Left = 56
    Top = 544
  end
  object tqNatOper: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select distinct nato_codigo, nato_descricao'
      'from naturezaoperacao'
      'where '
      '('
      'nato_codigo in'
      
        '                                         (Select nato_codigo fro' +
        'm  NotaVenda n'
      
        '                                           where  notv_datafat >' +
        '= :dtIni and notv_dataFat <= :dtFim and n.MOD_CODIGO IN ('#39'01'#39','#39'1' +
        'B'#39','#39'55'#39','#39'04'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and n.Emp_Codigo =:E' +
        'mpr'
      '                                          )'
      ' or'
      '    nato_codigo in'
      
        '                                         (Select nato_codigo fro' +
        'm NotaCompra n'
      
        '                                           where notc_datafatura' +
        ' >= :dtIni and notc_datafatura <= :dtFim and n.MOD_CODIGO IN ('#39'0' +
        '1'#39','#39'1B'#39','#39'55'#39','#39'04'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08'#39','#39'26'#39') and n.Emp_Codig' +
        'o =:Empr'
      '                                          )'
      ')')
    Left = 24
    Top = 544
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptUnknown
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptUnknown
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptUnknown
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptUnknown
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptUnknown
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptUnknown
      end>
  end
  object tqInfCompl: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select * from Mensagem'
      'where'
      '('
      
        '(cod_mensagem in (Select distinct cod_mensagem  from notavenda w' +
        'here notv_datafat >=:dtIni and notv_dataFat <=:dtFim'
      'and Emp_Codigo =:Empr))'
      ' or'
      
        '(cod_mensagem  in (Select distinct cod_mensagem  from notacompra' +
        ' where notc_datafatura >=:dtIni and notc_datafatura <=:dtFim'
      'and Emp_Codigo =:Empr))'
      ')')
    Left = 24
    Top = 592
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end>
  end
  object dspInfCompl: TDataSetProvider
    DataSet = tqInfCompl
    Left = 56
    Top = 592
  end
  object CDSInfCompl: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspInfCompl'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 592
    object CDSInfComplCOD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object CDSInfComplTEXTO: TBlobField
      FieldName = 'TEXTO'
      Size = 1
    end
  end
  object tqObservacoes: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select * from Observacoes')
    Left = 24
    Top = 640
  end
  object dspObservacoes: TDataSetProvider
    DataSet = tqObservacoes
    Left = 56
    Top = 640
  end
  object CDSObservacoes: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspObservacoes'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 640
    object CDSObservacoesCOD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object CDSObservacoesTXT: TBlobField
      FieldName = 'TXT'
      Size = 1
    end
  end
  object tqPlanoContas: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'Select distinct p.*'
      'from Plano_Contas p, Historico h'
      'where HIST_CONTABIL = COD_CTA'
      'and '
      '('
      
        '(Hist_codigo in (Select distinct Hist_codigo from notavenda wher' +
        'e notv_datafat >=:dtIni and notv_dataFat <=:dtFim and notavenda.' +
        'Emp_codigo =:Empr))'
      ' or'
      
        '(Hist_codigo in (Select distinct Hist_codigo from notacompra whe' +
        're notc_datafatura >=:dtIni and notc_datafatura <=:dtFim and not' +
        'acompra.Emp_codigo =:Empr))'
      ')'
      'order by Cod_CTA')
    Left = 24
    Top = 688
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptInput
      end>
  end
  object dspPlanoContas: TDataSetProvider
    DataSet = tqPlanoContas
    Left = 56
    Top = 688
  end
  object CDSPlanoContas: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspPlanoContas'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 688
    object CDSPlanoContasCOD_CTA: TStringField
      FieldName = 'COD_CTA'
      Size = 60
    end
    object CDSPlanoContasDT_ALT: TDateTimeField
      FieldName = 'DT_ALT'
    end
    object CDSPlanoContasCOD_NAT_CC: TStringField
      FieldName = 'COD_NAT_CC'
      Size = 2
    end
    object CDSPlanoContasIND_CTA: TStringField
      FieldName = 'IND_CTA'
      FixedChar = True
      Size = 1
    end
    object CDSPlanoContasNIVEL: TFloatField
      FieldName = 'NIVEL'
    end
    object CDSPlanoContasNOME_CTA: TStringField
      FieldName = 'NOME_CTA'
      Size = 60
    end
  end
  object tqDepartamento: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select * from Departamento')
    Left = 24
    Top = 734
  end
  object dspDepartamento: TDataSetProvider
    DataSet = tqDepartamento
    Left = 56
    Top = 734
  end
  object CDSDepartamento: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspDepartamento'
    AfterOpen = CDSAltItemAfterOpen
    Left = 88
    Top = 734
    object CDSDepartamentoDEP_CODIGO: TStringField
      FieldName = 'DEP_CODIGO'
      Size = 2
    end
    object CDSDepartamentoDEP_DESCRICAO: TStringField
      FieldName = 'DEP_DESCRICAO'
      Size = 30
    end
    object CDSDepartamentoVL_HORAH: TFloatField
      FieldName = 'VL_HORAH'
    end
    object CDSDepartamentoVL_HORAM: TFloatField
      FieldName = 'VL_HORAM'
    end
    object CDSDepartamentoDATA_ATUAL: TDateTimeField
      FieldName = 'DATA_ATUAL'
    end
    object CDSDepartamentoRESPONSAVEL: TStringField
      FieldName = 'RESPONSAVEL'
      Size = 30
    end
    object CDSDepartamentoDEP_ORDEM: TFloatField
      FieldName = 'DEP_ORDEM'
    end
    object CDSDepartamentoDEP_ABREVIACAO: TStringField
      FieldName = 'DEP_ABREVIACAO'
      Size = 7
    end
  end
  object tqNotaFiscalV: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select '
      'CASE WHEN NOTV_EMITENTE = '#39'P'#39' THEN'
      ' '#39'0'#39
      'ELSE'
      ' '#39'1'#39
      'END AS IND_EMIT,'
      'n.NOTA_SERIE, n.NOTA_NUMERO,'
      
        'BKP_SERIE, BKP_NUMERO, n.ENT_CODIGO, T.ENT_CODIGO as TRAN_ENTIDA' +
        'DE, MOD_CODIGO, '
      
        'CASE WHEN (CANP_CODIGO IS NOT NULL) OR (NFE_RESULTADO = '#39'101'#39')th' +
        'en'
      ' '#39'02'#39
      'ELSE'
      
        ' CASE WHEN (NFE_RESULTADO = '#39'301'#39') OR (NFE_RESULTADO = '#39'302'#39') TH' +
        'EN'
      '  '#39'04'#39
      ' ELSE'
      '  CASE WHEN (NFE_RESULTADO = '#39'102'#39') THEN'
      '   '#39'05'#39
      '  ELSE'
      '   CASE WHEN (NFE_RESULTADO = '#39'100'#39') THEN'
      '    CASE WHEN (NOTA_NUMERO_REF IS NOT NULL) THEN'
      '     '#39'06'#39
      '    ELSE'
      '     '#39'00'#39
      '    END'
      '   ELSE'
      '    '#39'00'#39
      '   END'
      '  END'
      ' END'
      'END AS COD_SIT,'
      'NFE_CHAVE, NOTV_DATAFAT, NOTV_DATASAIDA, NOTV_VALORCONTABIL,'
      'CASE WHEN PM = 0 THEN'
      ' '#39'2'#39
      'ELSE'
      ' CASE WHEN PM = 1 THEN'
      '  '#39'0'#39
      ' ELSE'
      '  '#39'1'#39
      ' END'
      'END AS IND_PGTO,'
      
        'NOTV_TOTALDESCONTO, (NOTV_TOTALPRODUTO*NOTV_ALIQDESCICM/100) AS ' +
        'VL_ABAT_NT, NOTV_TOTALPRODUTO,'
      'CASE WHEN NOTV_FRETE > 0 THEN'
      ' CASE WHEN NOTV_TIPOFRETE = '#39'C'#39' THEN'
      '  '#39'2'#39
      ' ELSE'
      '  '#39'1'#39
      ' END'
      'ELSE'
      ' '#39'3'#39
      'END AS IND_FRT, CODF_CODIGO,'
      
        'NOTV_FRETE, NOTV_SEGURO, NOTV_EMBALAGEM, NOTV_BCALICMS, NOTV_ICM' +
        'S, NOTV_BCALICMSUBS, NOTV_ICMSUBS,'
      'NOTV_IPI, NOTV_PIS, NOTV_COFINS, NOTV_PIS_ST, NOTV_COFINS_ST, '
      
        'COD_MENSAGEM, NOTV_MENSAGEM, COD_OBS, NOTV_OBS_LANCFISCAL, NOTV_' +
        'QTDEEMB as QTD_VOL, NOTV_PESOBRU, NOTV_PESOLIQ, T.TRAN_UFPLACA a' +
        's UF_ID,'
      'CASE WHEN (NOTV_PLACAVEIC = '#39#39') or (NOTV_PLACAVEIC is null) then'
      ' T.TRAN_PLACA'
      'else'
      ' NOTV_PLACAVEIC'
      'end as VEIC_ID, QTD_PARC, VL_TIT, REF_NUMERO'
      'FROM BACKUP_VENDA B,'
      'NOTAVENDA N'
      'LEFT JOIN TRANSPORTADORA T ON T.TRAN_CODIGO = N.TRAN_CODIGO'
      
        'LEFT JOIN (SELECT AVG(IRG_DIAS) AS PM, I.REG_CODIGO FROM ITEMREG' +
        'RA I GROUP BY REG_CODIGO) R'
      '       ON R.REG_CODIGO = N.REG_CODIGO'
      
        'LEFT JOIN (SELECT COUNT(TITC_NUMERO) AS QTD_PARC, SUM(TITC_VALOR' +
        ') AS VL_TIT, NOTA_SERIE, NOTA_NUMERO, ENT_CODIGO FROM TITCREDITO' +
        ' GROUP BY NOTA_SERIE, NOTA_NUMERO, ENT_CODIGO) TC'
      
        '       ON TC.NOTA_SERIE||TC.NOTA_NUMERO||TC.ENT_CODIGO = N.NOTA_' +
        'SERIE||N.NOTA_NUMERO||N.ENT_CODIGO'
      
        'LEFT JOIN ITEMNOTAVENDA I ON i.NOTA_SERIE||i.NOTA_NUMERO||i.ENT_' +
        'CODIGO = N.NOTA_SERIE||N.NOTA_NUMERO||N.ENT_CODIGO'
      
        'WHERE B.NOTA_SERIE||B.NOTA_NUMERO||B.ENT_CODIGO = N.NOTA_SERIE||' +
        'N.NOTA_NUMERO||N.ENT_CODIGO'
      
        '  AND MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39'04'#39','#39'55'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08' +
        #39','#39'26'#39')'
      '  AND NOTV_DATAFAT >= :dtIni and  NOTV_DATAFAT <= :dtFim'
      '  AND N.EMP_CODIGO = :Empr'
      'ORDER BY BKP_SERIE, BKP_NUMERO')
    Left = 200
    Top = 64
    ParamData = <
      item
        DataType = ftDateTime
        Name = 'dtIni'
        ParamType = ptUnknown
        Value = '01/04/2011'
      end
      item
        DataType = ftDateTime
        Name = 'dtFim'
        ParamType = ptUnknown
        Value = '30/04/2011'
      end
      item
        DataType = ftString
        Name = 'Empr'
        ParamType = ptUnknown
        Value = '001'
      end>
    object tqNotaFiscalVIND_EMIT: TStringField
      FieldName = 'IND_EMIT'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalVNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object tqNotaFiscalVNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object tqNotaFiscalVBKP_SERIE: TStringField
      FieldName = 'BKP_SERIE'
      Size = 3
    end
    object tqNotaFiscalVBKP_NUMERO: TStringField
      FieldName = 'BKP_NUMERO'
      Size = 9
    end
    object tqNotaFiscalVENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object tqNotaFiscalVTRAN_ENTIDADE: TStringField
      FieldName = 'TRAN_ENTIDADE'
      Size = 5
    end
    object tqNotaFiscalVMOD_CODIGO: TStringField
      FieldName = 'MOD_CODIGO'
      Size = 2
    end
    object tqNotaFiscalVCOD_SIT: TStringField
      FieldName = 'COD_SIT'
      FixedChar = True
      Size = 2
    end
    object tqNotaFiscalVNFE_CHAVE: TStringField
      FieldName = 'NFE_CHAVE'
      Size = 44
    end
    object tqNotaFiscalVNOTV_DATAFAT: TDateTimeField
      FieldName = 'NOTV_DATAFAT'
    end
    object tqNotaFiscalVNOTV_DATASAIDA: TDateTimeField
      FieldName = 'NOTV_DATASAIDA'
    end
    object tqNotaFiscalVNOTV_VALORCONTABIL: TFloatField
      FieldName = 'NOTV_VALORCONTABIL'
    end
    object tqNotaFiscalVIND_PGTO: TStringField
      FieldName = 'IND_PGTO'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalVNOTV_TOTALDESCONTO: TFloatField
      FieldName = 'NOTV_TOTALDESCONTO'
    end
    object tqNotaFiscalVVL_ABAT_NT: TFloatField
      FieldName = 'VL_ABAT_NT'
    end
    object tqNotaFiscalVNOTV_TOTALPRODUTO: TFloatField
      FieldName = 'NOTV_TOTALPRODUTO'
    end
    object tqNotaFiscalVIND_FRT: TStringField
      FieldName = 'IND_FRT'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalVNOTV_FRETE: TFloatField
      FieldName = 'NOTV_FRETE'
    end
    object tqNotaFiscalVNOTV_SEGURO: TFloatField
      FieldName = 'NOTV_SEGURO'
    end
    object tqNotaFiscalVNOTV_EMBALAGEM: TFloatField
      FieldName = 'NOTV_EMBALAGEM'
    end
    object tqNotaFiscalVNOTV_BCALICMS: TFloatField
      FieldName = 'NOTV_BCALICMS'
    end
    object tqNotaFiscalVNOTV_ICMS: TFloatField
      FieldName = 'NOTV_ICMS'
    end
    object tqNotaFiscalVNOTV_BCALICMSUBS: TFloatField
      FieldName = 'NOTV_BCALICMSUBS'
    end
    object tqNotaFiscalVNOTV_ICMSUBS: TFloatField
      FieldName = 'NOTV_ICMSUBS'
    end
    object tqNotaFiscalVNOTV_IPI: TFloatField
      FieldName = 'NOTV_IPI'
    end
    object tqNotaFiscalVNOTV_PIS: TFloatField
      FieldName = 'NOTV_PIS'
    end
    object tqNotaFiscalVNOTV_COFINS: TFloatField
      FieldName = 'NOTV_COFINS'
    end
    object tqNotaFiscalVNOTV_PIS_ST: TFloatField
      FieldName = 'NOTV_PIS_ST'
    end
    object tqNotaFiscalVNOTV_COFINS_ST: TFloatField
      FieldName = 'NOTV_COFINS_ST'
    end
    object tqNotaFiscalVCOD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object tqNotaFiscalVNOTV_MENSAGEM: TBlobField
      FieldName = 'NOTV_MENSAGEM'
      Size = 1
    end
    object tqNotaFiscalVCOD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object tqNotaFiscalVNOTV_OBS_LANCFISCAL: TMemoField
      FieldName = 'NOTV_OBS_LANCFISCAL'
      BlobType = ftMemo
      Size = 2000
    end
    object tqNotaFiscalVQTD_VOL: TFloatField
      FieldName = 'QTD_VOL'
    end
    object tqNotaFiscalVNOTV_PESOBRU: TFloatField
      FieldName = 'NOTV_PESOBRU'
    end
    object tqNotaFiscalVNOTV_PESOLIQ: TFloatField
      FieldName = 'NOTV_PESOLIQ'
    end
    object tqNotaFiscalVUF_ID: TStringField
      FieldName = 'UF_ID'
      Size = 2
    end
    object tqNotaFiscalVVEIC_ID: TStringField
      FieldName = 'VEIC_ID'
      Size = 8
    end
    object tqNotaFiscalVQTD_PARC: TFloatField
      FieldName = 'QTD_PARC'
    end
    object tqNotaFiscalVVL_TIT: TFloatField
      FieldName = 'VL_TIT'
    end
    object tqNotaFiscalVREF_NUMERO: TStringField
      FieldName = 'REF_NUMERO'
      Size = 9
    end
    object tqNotaFiscalVCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
  end
  object dspNotaFiscalV: TDataSetProvider
    DataSet = tqNotaFiscalV
    Left = 232
    Top = 64
  end
  object CDSNotaFiscalV: TClientDataSet
    Aggregates = <>
    FieldDefs = <
      item
        Name = 'IND_EMIT'
        Attributes = [faFixed]
        DataType = ftString
        Size = 1
      end
      item
        Name = 'NOTA_SERIE'
        DataType = ftString
        Size = 3
      end
      item
        Name = 'NOTA_NUMERO'
        DataType = ftString
        Size = 9
      end
      item
        Name = 'BKP_SERIE'
        DataType = ftString
        Size = 3
      end
      item
        Name = 'BKP_NUMERO'
        DataType = ftString
        Size = 9
      end
      item
        Name = 'ENT_CODIGO'
        DataType = ftString
        Size = 5
      end
      item
        Name = 'TRAN_ENTIDADE'
        DataType = ftString
        Size = 5
      end
      item
        Name = 'MOD_CODIGO'
        DataType = ftString
        Size = 2
      end
      item
        Name = 'COD_SIT'
        Attributes = [faFixed]
        DataType = ftString
        Size = 2
      end
      item
        Name = 'NFE_CHAVE'
        DataType = ftString
        Size = 44
      end
      item
        Name = 'NOTV_DATAFAT'
        DataType = ftDateTime
      end
      item
        Name = 'NOTV_DATASAIDA'
        DataType = ftDateTime
      end
      item
        Name = 'NOTV_VALORCONTABIL'
        DataType = ftFloat
      end
      item
        Name = 'IND_PGTO'
        Attributes = [faFixed]
        DataType = ftString
        Size = 1
      end
      item
        Name = 'NOTV_TOTALDESCONTO'
        DataType = ftFloat
      end
      item
        Name = 'VL_ABAT_NT'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_TOTALPRODUTO'
        DataType = ftFloat
      end
      item
        Name = 'IND_FRT'
        Attributes = [faFixed]
        DataType = ftString
        Size = 1
      end
      item
        Name = 'NOTV_FRETE'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_SEGURO'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_EMBALAGEM'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_BCALICMS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_ICMS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_BCALICMSUBS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_ICMSUBS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_IPI'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_PIS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_COFINS'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_PIS_ST'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_COFINS_ST'
        DataType = ftFloat
      end
      item
        Name = 'COD_MENSAGEM'
        DataType = ftString
        Size = 3
      end
      item
        Name = 'NOTV_MENSAGEM'
        DataType = ftBlob
        Size = 1
      end
      item
        Name = 'COD_OBS'
        DataType = ftString
        Size = 6
      end
      item
        Name = 'NOTV_OBS_LANCFISCAL'
        DataType = ftMemo
        Size = 2000
      end
      item
        Name = 'QTD_VOL'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_PESOBRU'
        DataType = ftFloat
      end
      item
        Name = 'NOTV_PESOLIQ'
        DataType = ftFloat
      end
      item
        Name = 'UF_ID'
        DataType = ftString
        Size = 2
      end
      item
        Name = 'VEIC_ID'
        DataType = ftString
        Size = 8
      end
      item
        Name = 'QTD_PARC'
        DataType = ftFloat
      end
      item
        Name = 'VL_TIT'
        DataType = ftFloat
      end
      item
        Name = 'REF_NUMERO'
        DataType = ftString
        Size = 9
      end
      item
        Name = 'CODF_CODIGO'
        DataType = ftString
        Size = 5
      end>
    IndexDefs = <
      item
        Name = 'DEFAULT_ORDER'
        Fields = 'BKP_SERIE;BKP_NUMERO'
      end
      item
        Name = 'CHANGEINDEX'
      end>
    Params = <>
    ProviderName = 'dspNotaFiscalV'
    StoreDefs = True
    Left = 264
    Top = 64
    object CDSNotaFiscalVIND_EMIT: TStringField
      FieldName = 'IND_EMIT'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalVNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object CDSNotaFiscalVNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object CDSNotaFiscalVBKP_SERIE: TStringField
      FieldName = 'BKP_SERIE'
      Size = 3
    end
    object CDSNotaFiscalVBKP_NUMERO: TStringField
      FieldName = 'BKP_NUMERO'
      Size = 9
    end
    object CDSNotaFiscalVENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSNotaFiscalVTRAN_ENTIDADE: TStringField
      FieldName = 'TRAN_ENTIDADE'
      Size = 5
    end
    object CDSNotaFiscalVMOD_CODIGO: TStringField
      FieldName = 'MOD_CODIGO'
      Size = 2
    end
    object CDSNotaFiscalVCOD_SIT: TStringField
      FieldName = 'COD_SIT'
      Size = 2
    end
    object CDSNotaFiscalVNFE_CHAVE: TStringField
      FieldName = 'NFE_CHAVE'
      Size = 44
    end
    object CDSNotaFiscalVNOTV_DATAFAT: TDateTimeField
      FieldName = 'NOTV_DATAFAT'
    end
    object CDSNotaFiscalVNOTV_DATASAIDA: TDateTimeField
      FieldName = 'NOTV_DATASAIDA'
    end
    object CDSNotaFiscalVNOTV_VALORCONTABIL: TFloatField
      FieldName = 'NOTV_VALORCONTABIL'
    end
    object CDSNotaFiscalVIND_PGTO: TStringField
      FieldName = 'IND_PGTO'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalVNOTV_TOTALDESCONTO: TFloatField
      FieldName = 'NOTV_TOTALDESCONTO'
    end
    object CDSNotaFiscalVVL_ABAT_NT: TFloatField
      FieldName = 'VL_ABAT_NT'
    end
    object CDSNotaFiscalVNOTV_TOTALPRODUTO: TFloatField
      FieldName = 'NOTV_TOTALPRODUTO'
    end
    object CDSNotaFiscalVIND_FRT: TStringField
      FieldName = 'IND_FRT'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalVNOTV_FRETE: TFloatField
      FieldName = 'NOTV_FRETE'
    end
    object CDSNotaFiscalVNOTV_SEGURO: TFloatField
      FieldName = 'NOTV_SEGURO'
    end
    object CDSNotaFiscalVNOTV_EMBALAGEM: TFloatField
      FieldName = 'NOTV_EMBALAGEM'
    end
    object CDSNotaFiscalVNOTV_BCALICMS: TFloatField
      FieldName = 'NOTV_BCALICMS'
    end
    object CDSNotaFiscalVNOTV_ICMS: TFloatField
      FieldName = 'NOTV_ICMS'
    end
    object CDSNotaFiscalVNOTV_BCALICMSUBS: TFloatField
      FieldName = 'NOTV_BCALICMSUBS'
    end
    object CDSNotaFiscalVNOTV_ICMSUBS: TFloatField
      FieldName = 'NOTV_ICMSUBS'
    end
    object CDSNotaFiscalVNOTV_IPI: TFloatField
      FieldName = 'NOTV_IPI'
    end
    object CDSNotaFiscalVNOTV_PIS: TFloatField
      FieldName = 'NOTV_PIS'
    end
    object CDSNotaFiscalVNOTV_COFINS: TFloatField
      FieldName = 'NOTV_COFINS'
    end
    object CDSNotaFiscalVNOTV_PIS_ST: TFloatField
      FieldName = 'NOTV_PIS_ST'
    end
    object CDSNotaFiscalVNOTV_COFINS_ST: TFloatField
      FieldName = 'NOTV_COFINS_ST'
    end
    object CDSNotaFiscalVCOD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object CDSNotaFiscalVNOTV_MENSAGEM: TBlobField
      FieldName = 'NOTV_MENSAGEM'
      Size = 1
    end
    object CDSNotaFiscalVCOD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object CDSNotaFiscalVNOTV_OBS_LANCFISCAL: TMemoField
      FieldName = 'NOTV_OBS_LANCFISCAL'
      BlobType = ftMemo
      Size = 2000
    end
    object CDSNotaFiscalVQTD_VOL: TFloatField
      FieldName = 'QTD_VOL'
    end
    object CDSNotaFiscalVNOTV_PESOBRU: TFloatField
      FieldName = 'NOTV_PESOBRU'
    end
    object CDSNotaFiscalVNOTV_PESOLIQ: TFloatField
      FieldName = 'NOTV_PESOLIQ'
    end
    object CDSNotaFiscalVUF_ID: TStringField
      FieldName = 'UF_ID'
      Size = 2
    end
    object CDSNotaFiscalVVEIC_ID: TStringField
      FieldName = 'VEIC_ID'
      Size = 8
    end
    object CDSNotaFiscalVQTD_PARC: TFloatField
      FieldName = 'QTD_PARC'
    end
    object CDSNotaFiscalVVL_TIT: TFloatField
      FieldName = 'VL_TIT'
    end
    object CDSNotaFiscalVREF_NUMERO: TStringField
      FieldName = 'REF_NUMERO'
      Size = 9
    end
    object CDSNotaFiscalVCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
  end
  object dsNotaFiscalV: TDataSource
    DataSet = CDSNotaFiscalV
    Left = 296
    Top = 64
  end
  object tqNotaFiscalC: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      'select '
      'CASE WHEN NOTC_EMITENTE = '#39'P'#39' THEN'
      ' '#39'0'#39
      'ELSE'
      ' '#39'1'#39
      'END AS IND_EMIT,'
      'n.NOTC_SERIE as NOTA_SERIE, n.NOTAC_NUMERO as NOTA_NUMERO,'
      
        'BKP_SERIE, BKP_NOTA, B.ENT_CODIGO, T.ENT_CODIGO as TRAN_ENTIDADE' +
        ', MOD_CODIGO, '
      
        'CASE WHEN (CANP_CODIGO IS NOT NULL) OR (NFCE_RESULTADO = '#39'101'#39')t' +
        'hen'
      ' '#39'02'#39
      'ELSE'
      
        ' CASE WHEN (NFCE_RESULTADO = '#39'301'#39') OR (NFCE_RESULTADO = '#39'302'#39') ' +
        'THEN'
      '  '#39'04'#39
      ' ELSE'
      '  CASE WHEN (NFCE_RESULTADO = '#39'102'#39') THEN'
      '   '#39'05'#39
      '  ELSE'
      '   CASE WHEN (NFCE_RESULTADO = '#39'100'#39') THEN'
      '    CASE WHEN (NOTAC_NUMERO_REF IS NOT NULL) THEN'
      '     '#39'06'#39
      '    ELSE'
      '     '#39'00'#39
      '    END'
      '   ELSE'
      '    '#39'00'#39
      '   END'
      '  END'
      ' END'
      'END AS COD_SIT,'
      
        'NFCE_CHAVE, NOTC_DATAFATURA, NOTC_DATAENTRADA, NOTC_VALORCONTABI' +
        'L,'
      'CASE WHEN PM = 0 THEN'
      ' '#39'2'#39
      'ELSE'
      ' CASE WHEN PM = 1 THEN'
      '  '#39'0'#39
      ' ELSE'
      '  '#39'1'#39
      ' END'
      'END AS IND_PGTO,'
      
        'NOTC_DESCONTO, (NOTC_TOTALPRODUTO*NOTC_DESCICMS/100) AS VL_ABAT_' +
        'NT, NOTC_TOTALPRODUTO,'
      'CASE WHEN NOTC_VALORFRETE > 0 THEN'
      ' CASE WHEN NOTC_TIPOFRETE = '#39'C'#39' THEN'
      '  '#39'2'#39
      ' ELSE'
      '  '#39'1'#39
      ' END'
      'ELSE'
      ' '#39'3'#39
      'END AS IND_FRT, CODF_CODIGO,'
      
        'NOTC_VALORFRETE, NOTC_VALORSEGURO, NOTC_DESP_ACESSORIA, NOTC_BCA' +
        'LCICMS, NOTC_VALORICMS, NOTC_BCALCICMSSUBS, NOTC_VALORICMSSUBS,'
      'NOTC_VALORIPI, '
      'NOTC_PIS, NOTC_COFINS, NOTC_PIS_ST, NOTC_COFINS_ST,'
      
        'COD_MENSAGEM, NOTC_MENSAGEM, COD_OBS, NOTC_OBS_LANCFISCAL, NOTC_' +
        'QTDEEMB as QTD_VOL, 0 NOTV_PESOBRU, 0 NOTV_PESOLIQ, TRAN_UFPLACA' +
        ' as UF_ID,'
      'CASE WHEN (NOTC_PLACAVEIC = '#39#39') or (NOTC_PLACAVEIC is null) then'
      ' TRAN_PLACA'
      'else'
      ' NOTC_PLACAVEIC'
      'end as VEIC_ID, QTD_PARC, VL_TIT'
      'FROM BACKUP_NOTACOMPRA B, '
      'NOTACOMPRA N'
      
        'LEFT JOIN (SELECT COUNT(TITC_NUMERO) AS QTD_PARC, SUM(TITC_VALOR' +
        ') AS VL_TIT, NOTC_SERIE, NOTAC_NUMERO, ENT_CODIGO'
      
        '             FROM TITCREDITO GROUP BY NOTC_SERIE, NOTAC_NUMERO, ' +
        'ENT_CODIGO) TC'
      
        '       ON TC.NOTC_SERIE||TC.NOTAC_NUMERO||TC.ENT_CODIGO = N.NOTC' +
        '_SERIE||N.NOTAC_NUMERO||N.ENT_CODIGO'
      
        'LEFT JOIN (SELECT AVG(IRG_DIAS) AS PM, I.REG_CODIGO FROM ITEMREG' +
        'RA I GROUP BY REG_CODIGO) R'
      '       ON R.REG_CODIGO = N.REG_CODIGO'
      'LEFT JOIN TRANSPORTADORA T ON T.TRAN_CODIGO = N.TRAN_CODIGO'
      
        'WHERE B.NOTC_SERIE||B.NOTAC_NUMERO||B.ENT_CODIGO = N.NOTC_SERIE|' +
        '|N.NOTAC_NUMERO||N.ENT_CODIGO'
      
        '  AND MOD_CODIGO IN ('#39'01'#39','#39'1B'#39','#39'04'#39','#39'55'#39','#39'06'#39','#39'29'#39','#39'28'#39','#39'07'#39','#39'08' +
        #39','#39'26'#39')'
      '  AND NOTC_DATAFATURA >= :dtIni and NOTC_DATAFATURA <= :dtFim'
      '  AND N.EMP_CODIGO = :Empr'
      'ORDER BY BKP_SERIE, BKP_NOTA')
    Left = 200
    Top = 112
    ParamData = <
      item
        DataType = ftDate
        Name = 'dtIni'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'dtFim'
        ParamType = ptInput
      end
      item
        DataType = ftString
        Name = 'EMPR'
        ParamType = ptInput
      end>
    object tqNotaFiscalCIND_EMIT: TStringField
      FieldName = 'IND_EMIT'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalCNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object tqNotaFiscalCNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object tqNotaFiscalCBKP_SERIE: TStringField
      FieldName = 'BKP_SERIE'
      Size = 3
    end
    object tqNotaFiscalCBKP_NOTA: TStringField
      FieldName = 'BKP_NOTA'
      Size = 9
    end
    object tqNotaFiscalCENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object tqNotaFiscalCTRAN_ENTIDADE: TStringField
      FieldName = 'TRAN_ENTIDADE'
      Size = 5
    end
    object tqNotaFiscalCMOD_CODIGO: TStringField
      FieldName = 'MOD_CODIGO'
      Size = 2
    end
    object tqNotaFiscalCCOD_SIT: TStringField
      FieldName = 'COD_SIT'
      FixedChar = True
      Size = 2
    end
    object tqNotaFiscalCNFCE_CHAVE: TStringField
      FieldName = 'NFCE_CHAVE'
      Size = 44
    end
    object tqNotaFiscalCNOTC_DATAFATURA: TDateTimeField
      FieldName = 'NOTC_DATAFATURA'
    end
    object tqNotaFiscalCNOTC_DATAENTRADA: TDateTimeField
      FieldName = 'NOTC_DATAENTRADA'
    end
    object tqNotaFiscalCNOTC_VALORCONTABIL: TFloatField
      FieldName = 'NOTC_VALORCONTABIL'
    end
    object tqNotaFiscalCIND_PGTO: TStringField
      FieldName = 'IND_PGTO'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalCNOTC_DESCONTO: TFloatField
      FieldName = 'NOTC_DESCONTO'
    end
    object tqNotaFiscalCVL_ABAT_NT: TFloatField
      FieldName = 'VL_ABAT_NT'
    end
    object tqNotaFiscalCNOTC_TOTALPRODUTO: TFloatField
      FieldName = 'NOTC_TOTALPRODUTO'
    end
    object tqNotaFiscalCIND_FRT: TStringField
      FieldName = 'IND_FRT'
      FixedChar = True
      Size = 1
    end
    object tqNotaFiscalCNOTC_VALORFRETE: TFloatField
      FieldName = 'NOTC_VALORFRETE'
    end
    object tqNotaFiscalCNOTC_VALORSEGURO: TFloatField
      FieldName = 'NOTC_VALORSEGURO'
    end
    object tqNotaFiscalCNOTC_DESP_ACESSORIA: TFloatField
      FieldName = 'NOTC_DESP_ACESSORIA'
    end
    object tqNotaFiscalCNOTC_BCALCICMS: TFloatField
      FieldName = 'NOTC_BCALCICMS'
    end
    object tqNotaFiscalCNOTC_VALORICMS: TFloatField
      FieldName = 'NOTC_VALORICMS'
    end
    object tqNotaFiscalCNOTC_BCALCICMSSUBS: TFloatField
      FieldName = 'NOTC_BCALCICMSSUBS'
    end
    object tqNotaFiscalCNOTC_VALORICMSSUBS: TFloatField
      FieldName = 'NOTC_VALORICMSSUBS'
    end
    object tqNotaFiscalCNOTC_VALORIPI: TFloatField
      FieldName = 'NOTC_VALORIPI'
    end
    object tqNotaFiscalCNOTC_PIS: TFloatField
      FieldName = 'NOTC_PIS'
    end
    object tqNotaFiscalCNOTC_COFINS: TFloatField
      FieldName = 'NOTC_COFINS'
    end
    object tqNotaFiscalCNOTC_PIS_ST: TFloatField
      FieldName = 'NOTC_PIS_ST'
    end
    object tqNotaFiscalCNOTC_COFINS_ST: TFloatField
      FieldName = 'NOTC_COFINS_ST'
    end
    object tqNotaFiscalCCOD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object tqNotaFiscalCNOTC_MENSAGEM: TBlobField
      FieldName = 'NOTC_MENSAGEM'
      Size = 1
    end
    object tqNotaFiscalCCOD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object tqNotaFiscalCNOTC_OBS_LANCFISCAL: TMemoField
      FieldName = 'NOTC_OBS_LANCFISCAL'
      BlobType = ftMemo
      Size = 2000
    end
    object tqNotaFiscalCQTD_VOL: TFloatField
      FieldName = 'QTD_VOL'
    end
    object tqNotaFiscalCNOTV_PESOBRU: TFloatField
      FieldName = 'NOTV_PESOBRU'
    end
    object tqNotaFiscalCNOTV_PESOLIQ: TFloatField
      FieldName = 'NOTV_PESOLIQ'
    end
    object tqNotaFiscalCUF_ID: TStringField
      FieldName = 'UF_ID'
      Size = 2
    end
    object tqNotaFiscalCVEIC_ID: TStringField
      FieldName = 'VEIC_ID'
      Size = 8
    end
    object tqNotaFiscalCQTD_PARC: TFloatField
      FieldName = 'QTD_PARC'
    end
    object tqNotaFiscalCVL_TIT: TFloatField
      FieldName = 'VL_TIT'
    end
    object tqNotaFiscalCCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
  end
  object dspNotaFiscalC: TDataSetProvider
    DataSet = tqNotaFiscalC
    Left = 232
    Top = 112
  end
  object CDSNotaFiscalC: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspNotaFiscalC'
    Left = 264
    Top = 112
    object CDSNotaFiscalCIND_EMIT: TStringField
      FieldName = 'IND_EMIT'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalCNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object CDSNotaFiscalCNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object CDSNotaFiscalCBKP_SERIE: TStringField
      FieldName = 'BKP_SERIE'
      Size = 3
    end
    object CDSNotaFiscalCBKP_NOTA: TStringField
      FieldName = 'BKP_NOTA'
      Size = 9
    end
    object CDSNotaFiscalCENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSNotaFiscalCTRAN_ENTIDADE: TStringField
      FieldName = 'TRAN_ENTIDADE'
      Size = 5
    end
    object CDSNotaFiscalCMOD_CODIGO: TStringField
      FieldName = 'MOD_CODIGO'
      Size = 2
    end
    object CDSNotaFiscalCCOD_SIT: TStringField
      FieldName = 'COD_SIT'
      FixedChar = True
      Size = 2
    end
    object CDSNotaFiscalCNFCE_CHAVE: TStringField
      FieldName = 'NFCE_CHAVE'
      Size = 44
    end
    object CDSNotaFiscalCNOTC_DATAFATURA: TDateTimeField
      FieldName = 'NOTC_DATAFATURA'
    end
    object CDSNotaFiscalCNOTC_DATAENTRADA: TDateTimeField
      FieldName = 'NOTC_DATAENTRADA'
    end
    object CDSNotaFiscalCNOTC_VALORCONTABIL: TFloatField
      FieldName = 'NOTC_VALORCONTABIL'
    end
    object CDSNotaFiscalCIND_PGTO: TStringField
      FieldName = 'IND_PGTO'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalCNOTC_DESCONTO: TFloatField
      FieldName = 'NOTC_DESCONTO'
    end
    object CDSNotaFiscalCVL_ABAT_NT: TFloatField
      FieldName = 'VL_ABAT_NT'
    end
    object CDSNotaFiscalCNOTC_TOTALPRODUTO: TFloatField
      FieldName = 'NOTC_TOTALPRODUTO'
    end
    object CDSNotaFiscalCIND_FRT: TStringField
      FieldName = 'IND_FRT'
      FixedChar = True
      Size = 1
    end
    object CDSNotaFiscalCNOTC_VALORFRETE: TFloatField
      FieldName = 'NOTC_VALORFRETE'
    end
    object CDSNotaFiscalCNOTC_VALORSEGURO: TFloatField
      FieldName = 'NOTC_VALORSEGURO'
    end
    object CDSNotaFiscalCNOTC_DESP_ACESSORIA: TFloatField
      FieldName = 'NOTC_DESP_ACESSORIA'
    end
    object CDSNotaFiscalCNOTC_BCALCICMS: TFloatField
      FieldName = 'NOTC_BCALCICMS'
    end
    object CDSNotaFiscalCNOTC_VALORICMS: TFloatField
      FieldName = 'NOTC_VALORICMS'
    end
    object CDSNotaFiscalCNOTC_BCALCICMSSUBS: TFloatField
      FieldName = 'NOTC_BCALCICMSSUBS'
    end
    object CDSNotaFiscalCNOTC_VALORICMSSUBS: TFloatField
      FieldName = 'NOTC_VALORICMSSUBS'
    end
    object CDSNotaFiscalCNOTC_VALORIPI: TFloatField
      FieldName = 'NOTC_VALORIPI'
    end
    object CDSNotaFiscalCNOTC_PIS: TFloatField
      FieldName = 'NOTC_PIS'
    end
    object CDSNotaFiscalCNOTC_COFINS: TFloatField
      FieldName = 'NOTC_COFINS'
    end
    object CDSNotaFiscalCNOTC_PIS_ST: TFloatField
      FieldName = 'NOTC_PIS_ST'
    end
    object CDSNotaFiscalCNOTC_COFINS_ST: TFloatField
      FieldName = 'NOTC_COFINS_ST'
    end
    object CDSNotaFiscalCCOD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object CDSNotaFiscalCNOTC_MENSAGEM: TBlobField
      FieldName = 'NOTC_MENSAGEM'
      Size = 1
    end
    object CDSNotaFiscalCCOD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object CDSNotaFiscalCNOTC_OBS_LANCFISCAL: TMemoField
      FieldName = 'NOTC_OBS_LANCFISCAL'
      BlobType = ftMemo
      Size = 2000
    end
    object CDSNotaFiscalCQTD_VOL: TFloatField
      FieldName = 'QTD_VOL'
    end
    object CDSNotaFiscalCNOTV_PESOBRU: TFloatField
      FieldName = 'NOTV_PESOBRU'
    end
    object CDSNotaFiscalCNOTV_PESOLIQ: TFloatField
      FieldName = 'NOTV_PESOLIQ'
    end
    object CDSNotaFiscalCUF_ID: TStringField
      FieldName = 'UF_ID'
      Size = 2
    end
    object CDSNotaFiscalCVEIC_ID: TStringField
      FieldName = 'VEIC_ID'
      Size = 8
    end
    object CDSNotaFiscalCQTD_PARC: TFloatField
      FieldName = 'QTD_PARC'
    end
    object CDSNotaFiscalCVL_TIT: TFloatField
      FieldName = 'VL_TIT'
    end
    object CDSNotaFiscalCCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
  end
  object dsNotaFiscalC: TDataSource
    DataSet = CDSNotaFiscalC
    Left = 296
    Top = 112
  end
  object tqItemNotaFiscalV: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalV
    SQL.Strings = (
      
        'SELECT DISTINCT i.NOTA_SERIE, i.NOTA_NUMERO, i.ENT_CODIGO, ITNV_' +
        'ITEM, I.PRO_CODIGO, REPLACE(ITNV_OBSERVACAO,PRO_NOME,'#39#39') AS DESC' +
        'R_COMPL, ITNV_QUANTIDADE, PRO_UNIDADE,'
      
        '       (ITNV_QUANTIDADE*ITNV_VALORUNIT) VL_ITEM, ITNV_DESCONTOIT' +
        'EM, '
      '  CASE WHEN ITNV_ESTOQUEBAIXADO = '#39'N'#39' THEN'
      '    '#39'1'#39
      '  ELSE'
      '    '#39'0'#39
      
        '  END AS IND_MOV, ITNV_CST, I.CODF_CODIGO, NATO_CODIGO AS ID_OPE' +
        'RACAO,'
      
        '       ITNV_BCALCICMS, ITNV_ALIQICMS, ITNV_ICMS, ITNV_BCALCICMSS' +
        'UBS, ITNV_ALIQICMSSUBS, ITNV_ICMSSUBS,'
      
        '       ITNV_CST_IPI, ITNV_COD_ENQ, ITNV_BCALCIPI, ITNV_ALIQIPI, ' +
        'ITNV_IPI, ITNV_CST_PIS, ITNV_BCALCPIS,'
      
        '       ITNV_ALIQPIS_P, ITNV_QT_BCALCPIS, ITNV_ALIQPIS_R, ITNV_PI' +
        'S, ITNV_CST_COFINS, ITNV_BCALCCOFINS,'
      
        '       ITNV_ALIQCOFINS_P, ITNV_QT_BCALCCOFINS, ITNV_ALIQCOFINS_R' +
        ', ITNV_COFINS, H.HIST_CONTABIL'
      ' FROM NOTAVENDA N, PRODUTO P, ITEMNOTAVENDA I'
      'LEFT JOIN HISTORICO H ON H.HIST_CODIGO = I.HIST_CODIGO'
      
        'WHERE N.NOTA_SERIE||N.NOTA_NUMERO||N.ENT_CODIGO = I.NOTA_SERIE||' +
        'I.NOTA_NUMERO||I.ENT_CODIGO'
      '  AND I.PRO_CODIGO = P.PRO_CODIGO')
    Left = 200
    Top = 256
    object tqItemNotaFiscalVNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object tqItemNotaFiscalVNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object tqItemNotaFiscalVENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object tqItemNotaFiscalVITNV_ITEM: TStringField
      FieldName = 'ITNV_ITEM'
      Size = 3
    end
    object tqItemNotaFiscalVPRO_CODIGO: TStringField
      FieldName = 'PRO_CODIGO'
    end
    object tqItemNotaFiscalVDESCR_COMPL: TStringField
      FieldName = 'DESCR_COMPL'
      Size = 40
    end
    object tqItemNotaFiscalVITNV_QUANTIDADE: TFloatField
      FieldName = 'ITNV_QUANTIDADE'
    end
    object tqItemNotaFiscalVPRO_UNIDADE: TStringField
      FieldName = 'PRO_UNIDADE'
      Size = 3
    end
    object tqItemNotaFiscalVVL_ITEM: TFloatField
      FieldName = 'VL_ITEM'
    end
    object tqItemNotaFiscalVITNV_DESCONTOITEM: TFloatField
      FieldName = 'ITNV_DESCONTOITEM'
    end
    object tqItemNotaFiscalVIND_MOV: TStringField
      FieldName = 'IND_MOV'
      FixedChar = True
      Size = 1
    end
    object tqItemNotaFiscalVITNV_CST: TStringField
      FieldName = 'ITNV_CST'
      Size = 3
    end
    object tqItemNotaFiscalVCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
    object tqItemNotaFiscalVID_OPERACAO: TStringField
      FieldName = 'ID_OPERACAO'
      Size = 2
    end
    object tqItemNotaFiscalVITNV_BCALCICMS: TFloatField
      FieldName = 'ITNV_BCALCICMS'
    end
    object tqItemNotaFiscalVITNV_ALIQICMS: TFloatField
      FieldName = 'ITNV_ALIQICMS'
    end
    object tqItemNotaFiscalVITNV_ICMS: TFloatField
      FieldName = 'ITNV_ICMS'
    end
    object tqItemNotaFiscalVITNV_BCALCICMSSUBS: TFloatField
      FieldName = 'ITNV_BCALCICMSSUBS'
    end
    object tqItemNotaFiscalVITNV_ALIQICMSSUBS: TFloatField
      FieldName = 'ITNV_ALIQICMSSUBS'
    end
    object tqItemNotaFiscalVITNV_ICMSSUBS: TFloatField
      FieldName = 'ITNV_ICMSSUBS'
    end
    object tqItemNotaFiscalVITNV_CST_IPI: TStringField
      FieldName = 'ITNV_CST_IPI'
      Size = 3
    end
    object tqItemNotaFiscalVITNV_COD_ENQ: TStringField
      FieldName = 'ITNV_COD_ENQ'
      Size = 3
    end
    object tqItemNotaFiscalVITNV_BCALCIPI: TFloatField
      FieldName = 'ITNV_BCALCIPI'
    end
    object tqItemNotaFiscalVITNV_ALIQIPI: TFloatField
      FieldName = 'ITNV_ALIQIPI'
    end
    object tqItemNotaFiscalVITNV_IPI: TFloatField
      FieldName = 'ITNV_IPI'
    end
    object tqItemNotaFiscalVITNV_CST_PIS: TStringField
      FieldName = 'ITNV_CST_PIS'
      Size = 3
    end
    object tqItemNotaFiscalVITNV_BCALCPIS: TFloatField
      FieldName = 'ITNV_BCALCPIS'
    end
    object tqItemNotaFiscalVITNV_ALIQPIS_P: TFloatField
      FieldName = 'ITNV_ALIQPIS_P'
    end
    object tqItemNotaFiscalVITNV_QT_BCALCPIS: TFloatField
      FieldName = 'ITNV_QT_BCALCPIS'
    end
    object tqItemNotaFiscalVITNV_ALIQPIS_R: TFloatField
      FieldName = 'ITNV_ALIQPIS_R'
    end
    object tqItemNotaFiscalVITNV_PIS: TFloatField
      FieldName = 'ITNV_PIS'
    end
    object tqItemNotaFiscalVITNV_CST_COFINS: TStringField
      FieldName = 'ITNV_CST_COFINS'
      Size = 3
    end
    object tqItemNotaFiscalVITNV_BCALCCOFINS: TFloatField
      FieldName = 'ITNV_BCALCCOFINS'
    end
    object tqItemNotaFiscalVITNV_ALIQCOFINS_P: TFloatField
      FieldName = 'ITNV_ALIQCOFINS_P'
    end
    object tqItemNotaFiscalVITNV_QT_BCALCCOFINS: TFloatField
      FieldName = 'ITNV_QT_BCALCCOFINS'
    end
    object tqItemNotaFiscalVITNV_ALIQCOFINS_R: TFloatField
      FieldName = 'ITNV_ALIQCOFINS_R'
    end
    object tqItemNotaFiscalVITNV_COFINS: TFloatField
      FieldName = 'ITNV_COFINS'
    end
    object tqItemNotaFiscalVHIST_CONTABIL: TStringField
      FieldName = 'HIST_CONTABIL'
      Size = 10
    end
  end
  object dspItemNotaFiscalV: TDataSetProvider
    DataSet = tqItemNotaFiscalV
    Left = 232
    Top = 256
  end
  object CDSItemNotaFiscalV: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspItemNotaFiscalV'
    Left = 264
    Top = 256
    object CDSItemNotaFiscalVITNV_ITEM: TStringField
      FieldName = 'ITNV_ITEM'
      Size = 3
    end
    object CDSItemNotaFiscalVPRO_CODIGO: TStringField
      FieldName = 'PRO_CODIGO'
    end
    object CDSItemNotaFiscalVDESCR_COMPL: TStringField
      FieldName = 'DESCR_COMPL'
      Size = 40
    end
    object CDSItemNotaFiscalVITNV_QUANTIDADE: TFloatField
      FieldName = 'ITNV_QUANTIDADE'
    end
    object CDSItemNotaFiscalVPRO_UNIDADE: TStringField
      FieldName = 'PRO_UNIDADE'
      Size = 3
    end
    object CDSItemNotaFiscalVVL_ITEM: TFloatField
      FieldName = 'VL_ITEM'
    end
    object CDSItemNotaFiscalVITNV_DESCONTOITEM: TFloatField
      FieldName = 'ITNV_DESCONTOITEM'
    end
    object CDSItemNotaFiscalVIND_MOV: TStringField
      FieldName = 'IND_MOV'
      FixedChar = True
      Size = 1
    end
    object CDSItemNotaFiscalVITNV_CST: TStringField
      FieldName = 'ITNV_CST'
      EditMask = '999'
      Size = 3
    end
    object CDSItemNotaFiscalVCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
    object CDSItemNotaFiscalVID_OPERACAO: TStringField
      FieldName = 'ID_OPERACAO'
      Size = 2
    end
    object CDSItemNotaFiscalVITNV_BCALCICMS: TFloatField
      FieldName = 'ITNV_BCALCICMS'
    end
    object CDSItemNotaFiscalVITNV_ALIQICMS: TFloatField
      FieldName = 'ITNV_ALIQICMS'
    end
    object CDSItemNotaFiscalVITNV_ICMS: TFloatField
      FieldName = 'ITNV_ICMS'
    end
    object CDSItemNotaFiscalVITNV_BCALCICMSSUBS: TFloatField
      FieldName = 'ITNV_BCALCICMSSUBS'
    end
    object CDSItemNotaFiscalVITNV_ALIQICMSSUBS: TFloatField
      FieldName = 'ITNV_ALIQICMSSUBS'
    end
    object CDSItemNotaFiscalVITNV_ICMSSUBS: TFloatField
      FieldName = 'ITNV_ICMSSUBS'
    end
    object CDSItemNotaFiscalVITNV_CST_IPI: TStringField
      FieldName = 'ITNV_CST_IPI'
      Size = 3
    end
    object CDSItemNotaFiscalVITNV_COD_ENQ: TStringField
      FieldName = 'ITNV_COD_ENQ'
      Size = 3
    end
    object CDSItemNotaFiscalVITNV_BCALCIPI: TFloatField
      FieldName = 'ITNV_BCALCIPI'
    end
    object CDSItemNotaFiscalVITNV_ALIQIPI: TFloatField
      FieldName = 'ITNV_ALIQIPI'
    end
    object CDSItemNotaFiscalVITNV_IPI: TFloatField
      FieldName = 'ITNV_IPI'
    end
    object CDSItemNotaFiscalVITNV_CST_PIS: TStringField
      FieldName = 'ITNV_CST_PIS'
      Size = 3
    end
    object CDSItemNotaFiscalVITNV_BCALCPIS: TFloatField
      FieldName = 'ITNV_BCALCPIS'
    end
    object CDSItemNotaFiscalVITNV_ALIQPIS_P: TFloatField
      FieldName = 'ITNV_ALIQPIS_P'
    end
    object CDSItemNotaFiscalVITNV_QT_BCALCPIS: TFloatField
      FieldName = 'ITNV_QT_BCALCPIS'
    end
    object CDSItemNotaFiscalVITNV_ALIQPIS_R: TFloatField
      FieldName = 'ITNV_ALIQPIS_R'
    end
    object CDSItemNotaFiscalVITNV_PIS: TFloatField
      FieldName = 'ITNV_PIS'
    end
    object CDSItemNotaFiscalVITNV_CST_COFINS: TStringField
      FieldName = 'ITNV_CST_COFINS'
      Size = 3
    end
    object CDSItemNotaFiscalVITNV_BCALCCOFINS: TFloatField
      FieldName = 'ITNV_BCALCCOFINS'
    end
    object CDSItemNotaFiscalVITNV_ALIQCOFINS_P: TFloatField
      FieldName = 'ITNV_ALIQCOFINS_P'
    end
    object CDSItemNotaFiscalVITNV_QT_BCALCCOFINS: TFloatField
      FieldName = 'ITNV_QT_BCALCCOFINS'
    end
    object CDSItemNotaFiscalVITNV_ALIQCOFINS_R: TFloatField
      FieldName = 'ITNV_ALIQCOFINS_R'
    end
    object CDSItemNotaFiscalVITNV_COFINS: TFloatField
      FieldName = 'ITNV_COFINS'
    end
    object CDSItemNotaFiscalVHIST_CONTABIL: TStringField
      FieldName = 'HIST_CONTABIL'
      Size = 10
    end
    object CDSItemNotaFiscalVNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object CDSItemNotaFiscalVNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object CDSItemNotaFiscalVENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
  end
  object tqC110: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalV
    SQL.Strings = (
      'Select * from Mensagem'
      'where COD_MENSAGEM =:COD_MENSAGEM')
    Left = 200
    Top = 448
    ParamData = <
      item
        DataType = ftString
        Name = 'COD_MENSAGEM'
        ParamType = ptInput
        Size = 4
      end>
  end
  object dspC110: TDataSetProvider
    DataSet = tqC110
    Left = 232
    Top = 448
  end
  object CDSC110: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspC110'
    Left = 264
    Top = 448
    object CDSC110COD_MENSAGEM: TStringField
      FieldName = 'COD_MENSAGEM'
      Size = 3
    end
    object CDSC110TEXTO: TBlobField
      FieldName = 'TEXTO'
      Size = 1
    end
  end
  object tqFatura: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'Select Rownum as Numero, Titc_numero, titc_datavenc, titc_valor,' +
        ' Ent_Codigo, Nota_numero, Notac_numero, Nota_Serie, Notc_Serie'
      'from Titcredito'
      'order by titc_datavenc,Titc_Numero')
    Left = 200
    Top = 496
  end
  object dspFatura: TDataSetProvider
    DataSet = tqFatura
    Left = 232
    Top = 496
  end
  object CDSFatura: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspFatura'
    Left = 264
    Top = 496
    object CDSFaturaTITC_NUMERO: TStringField
      FieldName = 'TITC_NUMERO'
    end
    object CDSFaturaTITC_DATAVENC: TDateTimeField
      FieldName = 'TITC_DATAVENC'
    end
    object CDSFaturaTITC_VALOR: TFloatField
      FieldName = 'TITC_VALOR'
    end
    object CDSFaturaNUMERO: TFloatField
      FieldName = 'NUMERO'
    end
    object CDSFaturaENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSFaturaNOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object CDSFaturaNOTAC_NUMERO: TStringField
      FieldName = 'NOTAC_NUMERO'
      Size = 9
    end
    object CDSFaturaNOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object CDSFaturaNOTC_SERIE: TStringField
      FieldName = 'NOTC_SERIE'
      Size = 3
    end
  end
  object tqC190V: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalV
    SQL.Strings = (
      'SELECT ITNV_CST, I.CODF_CODIGO, ITNV_ALIQICMS,'
      
        '       sum((itnv_quantidade*itnv_valorunit)+itnv_ipi+itnv_icmssu' +
        'bs) VL_OPR, '
      '       sum(ITNV_BCALCICMS) VL_BC_ICMS, '
      '       SUM(ITNV_ICMS) VL_ICMS,'
      '       SUM(ITNV_BCALCICMSSUBS) VL_BC_ICMS_ST, '
      '       SUM(ITNV_ICMSSUBS) VL_ICMS_ST,'
      '       SUM('
      '       CASE WHEN (ITNV_CST IN ('#39'020'#39','#39'070'#39')) THEN'
      '        ((itnv_quantidade*itnv_valorunit) -ITNV_BCALCICMS) '
      '       ELSE'
      '        0'
      '       END'
      '       ) AS VL_RED_BC, SUM(ITNV_IPI) VL_IPI'
      ' FROM ITEMNOTAVENDA I, NOTAVENDA N, ICMSDIFERIDO D'
      
        'WHERE N.NOTA_SERIE||N.NOTA_NUMERO||N.ENT_CODIGO = I.NOTA_SERIE||' +
        'I.NOTA_NUMERO||I.ENT_CODIGO'
      
        '  AND N.NOTA_SERIE = :NOTA_SERIE AND N.NOTA_NUMERO =:NOTA_NUMERO' +
        ' AND N.ENT_CODIGO =:ENT_CODIGO'
      '  AND I.ICMS_CODIGO = D.ICMS_CODIGO'
      'GROUP BY ITNV_CST, I.CODF_CODIGO, ITNV_ALIQICMS ')
    Left = 200
    Top = 352
    ParamData = <
      item
        DataType = ftString
        Name = 'NOTA_SERIE'
        ParamType = ptUnknown
        Size = 4
      end
      item
        DataType = ftString
        Name = 'NOTA_NUMERO'
        ParamType = ptUnknown
        Size = 10
      end
      item
        DataType = ftString
        Name = 'ENT_CODIGO'
        ParamType = ptUnknown
        Size = 6
      end>
  end
  object dspC190V: TDataSetProvider
    DataSet = tqC190V
    Left = 232
    Top = 352
  end
  object CDSC190V: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspC190V'
    Left = 264
    Top = 352
    object CDSC190VITNV_CST: TStringField
      FieldName = 'ITNV_CST'
      Size = 3
    end
    object CDSC190VCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
    object CDSC190VITNV_ALIQICMS: TFloatField
      FieldName = 'ITNV_ALIQICMS'
    end
    object CDSC190VVL_OPR: TFloatField
      FieldName = 'VL_OPR'
    end
    object CDSC190VVL_BC_ICMS: TFloatField
      FieldName = 'VL_BC_ICMS'
    end
    object CDSC190VVL_ICMS: TFloatField
      FieldName = 'VL_ICMS'
    end
    object CDSC190VVL_BC_ICMS_ST: TFloatField
      FieldName = 'VL_BC_ICMS_ST'
    end
    object CDSC190VVL_ICMS_ST: TFloatField
      FieldName = 'VL_ICMS_ST'
    end
    object CDSC190VVL_RED_BC: TFloatField
      FieldName = 'VL_RED_BC'
    end
    object CDSC190VVL_IPI: TFloatField
      FieldName = 'VL_IPI'
    end
  end
  object tqC195: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalV
    SQL.Strings = (
      'SELECT * from OBS_LANCFISCAL'
      'WHERE COD_OBS = :COD_OBS')
    Left = 200
    Top = 544
    ParamData = <
      item
        DataType = ftString
        Name = 'COD_OBS'
        ParamType = ptInput
        Size = 7
      end>
  end
  object dspC195: TDataSetProvider
    DataSet = tqC195
    Left = 232
    Top = 544
  end
  object CDSC195: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspC195'
    Left = 264
    Top = 544
    object CDSC195COD_OBS: TStringField
      FieldName = 'COD_OBS'
      Size = 6
    end
    object CDSC195TXT: TBlobField
      FieldName = 'TXT'
      Size = 1
    end
  end
  object tqItemNotaFiscalC: TQuery
    DatabaseName = 'Industrial'
    SQL.Strings = (
      
        'SELECT DISTINCT N.NOTC_SERIE, N.NOTAC_NUMERO, N.ENT_CODIGO, NOTC' +
        '_ITEM, I.PRO_CODIGO, REPLACE(ITNC_OBSERVACAO,PRO_NOME,'#39#39') AS DES' +
        'CR_COMPL, ITNC_QUANTIDADE, PRO_UNIDADE,'
      '       (ITNC_QUANTIDADE*ITNC_VALORUNIT) VL_ITEM, ITNC_DESCONTO,'
      '  CASE WHEN ITNC_ESTOQUEBAIXADO = '#39'N'#39' THEN'
      '    '#39'1'#39
      '  ELSE'
      '    '#39'0'#39
      
        '  END AS IND_MOV, ITNC_CST, I.CODF_CODIGO, NATO_CODIGO AS ID_OPE' +
        'RACAO,'
      '       ITNC_BCALCICMS, ITNC_ALIQICMS, ITNC_ICMS, '
      '       ITNC_BCALCICMSSUBS, ITNC_ALIQICMSSUBS, ITNC_ICMSSUBS,'
      
        '       ITNC_CST_IPI, ITNC_COD_ENQ, ITNC_BCALCIPI, ITNC_ALIQIPI, ' +
        'ITNC_IPI,'
      
        '       ITNC_CST_PIS, ITNC_BCALCPIS, ITNC_ALIQPIS_P, ITNC_QT_BCAL' +
        'CPIS, ITNC_ALIQPIS_R, ITNC_PIS,'
      
        '       ITNC_CST_COFINS, ITNC_BCALCCOFINS, ITNC_ALIQCOFINS_P, ITN' +
        'C_QT_BCALCCOFINS, ITNC_ALIQCOFINS_R, ITNC_COFINS,'
      '       H.HIST_CONTABIL, REF_NOTAC_NUMERO'
      ' FROM ITEMNOTACOMPRA I, PRODUTO P, NOTACOMPRA N'
      'LEFT JOIN HISTORICO H ON H.HIST_CODIGO = N.HIST_CODIGO'
      
        'WHERE N.NOTC_SERIE||N.NOTAC_NUMERO||N.ENT_CODIGO = I.NOTC_SERIE|' +
        '|I.NOTAC_NUMERO||I.ENT_CODIGO'
      '  AND I.PRO_CODIGO = P.PRO_CODIGO')
    Left = 200
    Top = 304
  end
  object dspItemNotaFiscalC: TDataSetProvider
    DataSet = tqItemNotaFiscalC
    Left = 232
    Top = 304
  end
  object CDSItemNotaFiscalC: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspItemNotaFiscalC'
    Left = 264
    Top = 304
    object CDSItemNotaFiscalCNOTC_SERIE: TStringField
      FieldName = 'NOTC_SERIE'
      Size = 3
    end
    object CDSItemNotaFiscalCNOTAC_NUMERO: TStringField
      FieldName = 'NOTAC_NUMERO'
      Size = 9
    end
    object CDSItemNotaFiscalCENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSItemNotaFiscalCNOTC_ITEM: TStringField
      FieldName = 'NOTC_ITEM'
      Size = 2
    end
    object CDSItemNotaFiscalCPRO_CODIGO: TStringField
      FieldName = 'PRO_CODIGO'
    end
    object CDSItemNotaFiscalCDESCR_COMPL: TStringField
      FieldName = 'DESCR_COMPL'
      Size = 60
    end
    object CDSItemNotaFiscalCITNC_QUANTIDADE: TFloatField
      FieldName = 'ITNC_QUANTIDADE'
    end
    object CDSItemNotaFiscalCPRO_UNIDADE: TStringField
      FieldName = 'PRO_UNIDADE'
      Size = 3
    end
    object CDSItemNotaFiscalCVL_ITEM: TFloatField
      FieldName = 'VL_ITEM'
    end
    object CDSItemNotaFiscalCIND_MOV: TStringField
      FieldName = 'IND_MOV'
      FixedChar = True
      Size = 1
    end
    object CDSItemNotaFiscalCITNC_CST: TStringField
      FieldName = 'ITNC_CST'
      EditMask = '999'
      Size = 3
    end
    object CDSItemNotaFiscalCCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
    object CDSItemNotaFiscalCID_OPERACAO: TStringField
      FieldName = 'ID_OPERACAO'
      Size = 2
    end
    object CDSItemNotaFiscalCITNC_BCALCICMS: TFloatField
      FieldName = 'ITNC_BCALCICMS'
    end
    object CDSItemNotaFiscalCITNC_ALIQICMS: TFloatField
      FieldName = 'ITNC_ALIQICMS'
    end
    object CDSItemNotaFiscalCITNC_ICMS: TFloatField
      FieldName = 'ITNC_ICMS'
    end
    object CDSItemNotaFiscalCITNC_BCALCICMSSUBS: TFloatField
      FieldName = 'ITNC_BCALCICMSSUBS'
    end
    object CDSItemNotaFiscalCITNC_ALIQICMSSUBS: TFloatField
      FieldName = 'ITNC_ALIQICMSSUBS'
    end
    object CDSItemNotaFiscalCITNC_ICMSSUBS: TFloatField
      FieldName = 'ITNC_ICMSSUBS'
    end
    object CDSItemNotaFiscalCITNC_CST_IPI: TStringField
      FieldName = 'ITNC_CST_IPI'
      Size = 3
    end
    object CDSItemNotaFiscalCITNC_COD_ENQ: TStringField
      FieldName = 'ITNC_COD_ENQ'
      Size = 3
    end
    object CDSItemNotaFiscalCITNC_BCALCIPI: TFloatField
      FieldName = 'ITNC_BCALCIPI'
    end
    object CDSItemNotaFiscalCITNC_ALIQIPI: TFloatField
      FieldName = 'ITNC_ALIQIPI'
    end
    object CDSItemNotaFiscalCITNC_IPI: TFloatField
      FieldName = 'ITNC_IPI'
    end
    object CDSItemNotaFiscalCITNC_CST_PIS: TStringField
      FieldName = 'ITNC_CST_PIS'
      Size = 3
    end
    object CDSItemNotaFiscalCITNC_BCALCPIS: TFloatField
      FieldName = 'ITNC_BCALCPIS'
    end
    object CDSItemNotaFiscalCITNC_ALIQPIS_P: TFloatField
      FieldName = 'ITNC_ALIQPIS_P'
    end
    object CDSItemNotaFiscalCITNC_QT_BCALCPIS: TFloatField
      FieldName = 'ITNC_QT_BCALCPIS'
    end
    object CDSItemNotaFiscalCITNC_ALIQPIS_R: TFloatField
      FieldName = 'ITNC_ALIQPIS_R'
    end
    object CDSItemNotaFiscalCITNC_PIS: TFloatField
      FieldName = 'ITNC_PIS'
    end
    object CDSItemNotaFiscalCITNC_CST_COFINS: TStringField
      FieldName = 'ITNC_CST_COFINS'
      Size = 3
    end
    object CDSItemNotaFiscalCITNC_BCALCCOFINS: TFloatField
      FieldName = 'ITNC_BCALCCOFINS'
    end
    object CDSItemNotaFiscalCITNC_ALIQCOFINS_P: TFloatField
      FieldName = 'ITNC_ALIQCOFINS_P'
    end
    object CDSItemNotaFiscalCITNC_QT_BCALCCOFINS: TFloatField
      FieldName = 'ITNC_QT_BCALCCOFINS'
    end
    object CDSItemNotaFiscalCITNC_ALIQCOFINS_R: TFloatField
      FieldName = 'ITNC_ALIQCOFINS_R'
    end
    object CDSItemNotaFiscalCITNC_COFINS: TFloatField
      FieldName = 'ITNC_COFINS'
    end
    object CDSItemNotaFiscalCHIST_CONTABIL: TStringField
      FieldName = 'HIST_CONTABIL'
      Size = 10
    end
    object CDSItemNotaFiscalCREF_NOTAC_NUMERO: TStringField
      FieldName = 'REF_NOTAC_NUMERO'
      Size = 9
    end
    object CDSItemNotaFiscalCITNC_DESCONTO: TFloatField
      FieldName = 'ITNC_DESCONTO'
    end
  end
  object tqC190C: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalC
    SQL.Strings = (
      
        'SELECT ITNC_CST, replace(I.CODF_CODIGO,'#39'.'#39','#39#39')as CODF_CODIGO, IT' +
        'NC_ALIQICMS,'
      
        '       sum((ITNC_QUANTIDADE*ITNC_VALORUNIT)-ITNC_DESCONTO+ITNC_V' +
        'ALORFRETE+ITNC_SEGURO+ITNC_ENCARGOS+ITNC_IPI+ITNC_ICMSSUBS) VL_O' +
        'PR,'
      '       SUM ('
      '       CASE WHEN (ITNC_BCALCICMS=0 AND ITNC_ICMS<>0) THEN'
      
        '         ((ITNC_QUANTIDADE*ITNC_VALORUNIT)-ITNC_DESCONTO+ITNC_VA' +
        'LORFRETE+ITNC_SEGURO+ITNC_ENCARGOS)'
      '       ELSE '
      '         (ITNC_BCALCICMS)'
      '       END )AS VL_BC_ICMS, '
      
        '       SUM(ITNC_ICMS) VL_ICMS, SUM(ITNC_BCALCICMSSUBS) VL_BC_ICM' +
        'S_ST, SUM(ITNC_ICMSSUBS) VL_ICMS_ST,'
      
        '       SUM((ITNC_QUANTIDADE*ITNC_VALORUNIT)-ITNC_BCALCICMS) VL_R' +
        'ED_BC, SUM(ITNC_IPI) VL_IPI'
      ' FROM ITEMNOTACOMPRA I, NOTACOMPRA N'
      
        'WHERE N.NOTC_SERIE||N.NOTAC_NUMERO||N.ENT_CODIGO = I.NOTC_SERIE|' +
        '|I.NOTAC_NUMERO||I.ENT_CODIGO'
      
        '  AND N.NOTC_SERIE = :NOTA_SERIE AND N.NOTAC_NUMERO =:NOTA_NUMER' +
        'O AND N.ENT_CODIGO =:ENT_CODIGO'
      'GROUP BY ITNC_CST, I.CODF_CODIGO, ITNC_ALIQICMS')
    Left = 200
    Top = 400
    ParamData = <
      item
        DataType = ftString
        Name = 'NOTA_SERIE'
        ParamType = ptUnknown
        Size = 4
      end
      item
        DataType = ftString
        Name = 'NOTA_NUMERO'
        ParamType = ptUnknown
        Size = 10
      end
      item
        DataType = ftString
        Name = 'ENT_CODIGO'
        ParamType = ptUnknown
        Size = 6
      end>
  end
  object dspC190C: TDataSetProvider
    DataSet = tqC190C
    Left = 232
    Top = 400
  end
  object CDSC190C: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspC190C'
    Left = 264
    Top = 400
    object CDSC190CITNC_CST: TStringField
      FieldName = 'ITNC_CST'
      Size = 3
    end
    object CDSC190CCODF_CODIGO: TStringField
      FieldName = 'CODF_CODIGO'
      Size = 5
    end
    object CDSC190CITNC_ALIQICMS: TFloatField
      FieldName = 'ITNC_ALIQICMS'
    end
    object CDSC190CVL_OPR: TFloatField
      FieldName = 'VL_OPR'
    end
    object CDSC190CVL_BC_ICMS: TFloatField
      FieldName = 'VL_BC_ICMS'
    end
    object CDSC190CVL_ICMS: TFloatField
      FieldName = 'VL_ICMS'
    end
    object CDSC190CVL_BC_ICMS_ST: TFloatField
      FieldName = 'VL_BC_ICMS_ST'
    end
    object CDSC190CVL_ICMS_ST: TFloatField
      FieldName = 'VL_ICMS_ST'
    end
    object CDSC190CVL_RED_BC: TFloatField
      FieldName = 'VL_RED_BC'
    end
    object CDSC190CVL_IPI: TFloatField
      FieldName = 'VL_IPI'
    end
  end
  object tqC113: TQuery
    DatabaseName = 'Industrial'
    DataSource = dsNotaFiscalV
    SQL.Strings = (
      'Select * from NOTA_REFERENCIADA'
      
        'where NOTA_SERIE = :NOTA_SERIE AND NOTA_NUMERO =:NOTA_NUMERO AND' +
        ' ENT_CODIGO =:ENT_CODIGO')
    Left = 200
    Top = 168
    ParamData = <
      item
        DataType = ftString
        Name = 'NOTA_SERIE'
        ParamType = ptUnknown
        Size = 4
      end
      item
        DataType = ftString
        Name = 'NOTA_NUMERO'
        ParamType = ptUnknown
        Size = 10
      end
      item
        DataType = ftString
        Name = 'ENT_CODIGO'
        ParamType = ptUnknown
        Size = 6
      end>
  end
  object dspC113: TDataSetProvider
    DataSet = tqC113
    Left = 232
    Top = 168
  end
  object CDSC113: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspC113'
    Left = 264
    Top = 168
    object CDSC113ID: TFloatField
      FieldName = 'ID'
    end
    object CDSC113NOTA_SERIE: TStringField
      FieldName = 'NOTA_SERIE'
      Size = 3
    end
    object CDSC113NOTA_NUMERO: TStringField
      FieldName = 'NOTA_NUMERO'
      Size = 9
    end
    object CDSC113NOTC_SERIE: TStringField
      FieldName = 'NOTC_SERIE'
      Size = 3
    end
    object CDSC113NOTAC_NUMERO: TStringField
      FieldName = 'NOTAC_NUMERO'
      Size = 9
    end
    object CDSC113ENT_CODIGO: TStringField
      FieldName = 'ENT_CODIGO'
      Size = 5
    end
    object CDSC113EMP_CODIGO: TStringField
      FieldName = 'EMP_CODIGO'
      Size = 3
    end
    object CDSC113CUF: TFloatField
      FieldName = 'CUF'
    end
    object CDSC113DATA_DOC: TFloatField
      FieldName = 'DATA_DOC'
    end
    object CDSC113CNPJ: TStringField
      FieldName = 'CNPJ'
      Size = 14
    end
    object CDSC113MOD: TFloatField
      FieldName = 'MOD'
    end
    object CDSC113SERIE: TFloatField
      FieldName = 'SERIE'
    end
    object CDSC113NNF: TFloatField
      FieldName = 'NNF'
    end
  end
  object E510: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 504
    Top = 80
    object E510CFOP: TStringField
      FieldName = 'CFOP'
    end
    object E510CST_IPI: TStringField
      FieldName = 'CST_IPI'
    end
    object E510VL_CONT_IPI: TFloatField
      FieldName = 'VL_CONT_IPI'
    end
    object E510VL_BC_IPI: TFloatField
      FieldName = 'VL_BC_IPI'
    end
    object E510VL_IPI: TFloatField
      FieldName = 'VL_IPI'
    end
  end
  object E110: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 504
    Top = 40
    object E110VL_TOT_DEBITOS: TFloatField
      FieldName = 'VL_TOT_DEBITOS'
    end
    object E110VL_TOT_CREDITOS: TFloatField
      FieldName = 'VL_TOT_CREDITOS'
    end
  end
  object D100: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 504
    Top = 168
    object D100COD_PART: TStringField
      FieldName = 'COD_PART'
    end
    object D100COD_MOD: TStringField
      FieldName = 'COD_MOD'
    end
    object D100COD_SIT: TStringField
      FieldName = 'COD_SIT'
    end
    object D100SER: TStringField
      FieldName = 'SER'
    end
    object D100NUM_DOC: TStringField
      FieldName = 'NUM_DOC'
    end
    object D100CHV_CTE: TStringField
      FieldName = 'CHV_CTE'
      Size = 44
    end
    object D100DT_A_P: TDateField
      FieldName = 'DT_A_P'
    end
    object D100VL_DOC: TFloatField
      FieldName = 'VL_DOC'
    end
    object D100VL_DESC: TFloatField
      FieldName = 'VL_DESC'
    end
    object D100VL_SERV: TFloatField
      FieldName = 'VL_SERV'
    end
    object D100VL_BC_ICMS: TFloatField
      FieldName = 'VL_BC_ICMS'
    end
    object D100VL_ICMS: TFloatField
      FieldName = 'VL_ICMS'
    end
    object D100VL_NT: TFloatField
      FieldName = 'VL_NT'
    end
    object D100COD_CTA: TStringField
      FieldName = 'COD_CTA'
    end
    object D100IND_FRT: TIntegerField
      FieldName = 'IND_FRT'
    end
    object D100DT_DOC: TStringField
      FieldName = 'DT_DOC'
    end
    object D100CFOP: TStringField
      FieldName = 'CFOP'
    end
    object D100ALIQ: TFloatField
      FieldName = 'ALIQ'
    end
    object D100IND_EMIT: TIntegerField
      FieldName = 'IND_EMIT'
    end
  end
end
